<?
include "../db_config.php";
echo "{\"totalNum\":";
$bssid = $HTTP_GET_VARS['bssid'];

$totalNum = '0';
$condition = "bssid like '$bssid'";
$sql = "select * from wps_ap_info where $condition";
$result = mysql_query($sql);
if($data = mysql_fetch_array($result))
	$totalNum = $data['sourceNum'];

echo $totalNum . ",\"Points\":[";

$sql = "select * from wps_ap_detection_log where id = ".$data[id];
$result = mysql_query($sql);
$i = 0;
$del = "";
while($data = mysql_fetch_array($result))
{
	$lat = $data['latitude'];
	$lng = $data['longitude'];
	$snr = $data['snr'];
	$bssid = $bssid;
	$sig = $data['signal'];
	$noise = $data['noise'];
	$detectTime = $data['detectTime'];


	$str ="";
	foreach($data as $key => $value)
	{
		//ignore number key
		if(is_int($key))
			continue;
			/*
		if($value == "" || $value == null)
			$value = "\"\"";
			*/
		$str .= "\"$key\":\"$value\",";
	}

	//eliminate final ,
	$str = substr($str, 0, -1);
	echo "$del{"."$str"."}";

	/*
	echo $del;
	echo "{\"lat\":$lat,\"lng\":$lng,\"SNR\":$snr,\"Sig\":$sig,";
	echo "\"Noise\":$noise,\"bssid\":\"$bssid\"}";
	*/
	if($del == "")
		$del = ", ";
	//echo "addmarker($lat, $lng, $no, '$ssids');\n"; 
	$i++;
}
echo "]}";

?>

